| Conditions | 2 |
| Total Lines | 240 |
| Code Lines | 90 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /* |
||
| 50 | constructor(wavBuffer=null) { |
||
| 51 | super(); |
||
| 52 | // Include 'RF64' as a supported container format |
||
| 53 | this.supported_containers.push('RF64'); |
||
| 54 | /** |
||
| 55 | * Audio formats. |
||
| 56 | * Formats not listed here should be set to 65534, |
||
| 57 | * the code for WAVE_FORMAT_EXTENSIBLE |
||
| 58 | * @enum {number} |
||
| 59 | * @protected |
||
| 60 | */ |
||
| 61 | this.WAV_AUDIO_FORMATS = { |
||
| 62 | '4': 17, |
||
| 63 | '8': 1, |
||
| 64 | '8a': 6, |
||
| 65 | '8m': 7, |
||
| 66 | '16': 1, |
||
| 67 | '24': 1, |
||
| 68 | '32': 1, |
||
| 69 | '32f': 3, |
||
| 70 | '64': 3 |
||
| 71 | }; |
||
| 72 | /** |
||
| 73 | * The data of the 'fmt' chunk. |
||
| 74 | * @type {!Object<string, *>} |
||
| 75 | */ |
||
| 76 | this.fmt = { |
||
| 77 | /** @type {string} */ |
||
| 78 | chunkId: '', |
||
| 79 | /** @type {number} */ |
||
| 80 | chunkSize: 0, |
||
| 81 | /** @type {number} */ |
||
| 82 | audioFormat: 0, |
||
| 83 | /** @type {number} */ |
||
| 84 | numChannels: 0, |
||
| 85 | /** @type {number} */ |
||
| 86 | sampleRate: 0, |
||
| 87 | /** @type {number} */ |
||
| 88 | byteRate: 0, |
||
| 89 | /** @type {number} */ |
||
| 90 | blockAlign: 0, |
||
| 91 | /** @type {number} */ |
||
| 92 | bitsPerSample: 0, |
||
| 93 | /** @type {number} */ |
||
| 94 | cbSize: 0, |
||
| 95 | /** @type {number} */ |
||
| 96 | validBitsPerSample: 0, |
||
| 97 | /** @type {number} */ |
||
| 98 | dwChannelMask: 0, |
||
| 99 | /** |
||
| 100 | * 4 32-bit values representing a 128-bit ID |
||
| 101 | * @type {!Array<number>} |
||
| 102 | */ |
||
| 103 | subformat: [] |
||
| 104 | }; |
||
| 105 | /** |
||
| 106 | * The data of the 'fact' chunk. |
||
| 107 | * @type {!Object<string, *>} |
||
| 108 | */ |
||
| 109 | this.fact = { |
||
| 110 | /** @type {string} */ |
||
| 111 | chunkId: '', |
||
| 112 | /** @type {number} */ |
||
| 113 | chunkSize: 0, |
||
| 114 | /** @type {number} */ |
||
| 115 | dwSampleLength: 0 |
||
| 116 | }; |
||
| 117 | /** |
||
| 118 | * The data of the 'cue ' chunk. |
||
| 119 | * @type {!Object<string, *>} |
||
| 120 | */ |
||
| 121 | this.cue = { |
||
| 122 | /** @type {string} */ |
||
| 123 | chunkId: '', |
||
| 124 | /** @type {number} */ |
||
| 125 | chunkSize: 0, |
||
| 126 | /** @type {number} */ |
||
| 127 | dwCuePoints: 0, |
||
| 128 | /** @type {!Array<!Object>} */ |
||
| 129 | points: [], |
||
| 130 | }; |
||
| 131 | /** |
||
| 132 | * The data of the 'smpl' chunk. |
||
| 133 | * @type {!Object<string, *>} |
||
| 134 | */ |
||
| 135 | this.smpl = { |
||
| 136 | /** @type {string} */ |
||
| 137 | chunkId: '', |
||
| 138 | /** @type {number} */ |
||
| 139 | chunkSize: 0, |
||
| 140 | /** @type {number} */ |
||
| 141 | dwManufacturer: 0, |
||
| 142 | /** @type {number} */ |
||
| 143 | dwProduct: 0, |
||
| 144 | /** @type {number} */ |
||
| 145 | dwSamplePeriod: 0, |
||
| 146 | /** @type {number} */ |
||
| 147 | dwMIDIUnityNote: 0, |
||
| 148 | /** @type {number} */ |
||
| 149 | dwMIDIPitchFraction: 0, |
||
| 150 | /** @type {number} */ |
||
| 151 | dwSMPTEFormat: 0, |
||
| 152 | /** @type {number} */ |
||
| 153 | dwSMPTEOffset: 0, |
||
| 154 | /** @type {number} */ |
||
| 155 | dwNumSampleLoops: 0, |
||
| 156 | /** @type {number} */ |
||
| 157 | dwSamplerData: 0, |
||
| 158 | /** @type {!Array<!Object>} */ |
||
| 159 | loops: [] |
||
| 160 | }; |
||
| 161 | /** |
||
| 162 | * The data of the 'bext' chunk. |
||
| 163 | * @type {!Object<string, *>} |
||
| 164 | */ |
||
| 165 | this.bext = { |
||
| 166 | /** @type {string} */ |
||
| 167 | chunkId: '', |
||
| 168 | /** @type {number} */ |
||
| 169 | chunkSize: 0, |
||
| 170 | /** @type {string} */ |
||
| 171 | description: '', //256 |
||
| 172 | /** @type {string} */ |
||
| 173 | originator: '', //32 |
||
| 174 | /** @type {string} */ |
||
| 175 | originatorReference: '', //32 |
||
| 176 | /** @type {string} */ |
||
| 177 | originationDate: '', //10 |
||
| 178 | /** @type {string} */ |
||
| 179 | originationTime: '', //8 |
||
| 180 | /** |
||
| 181 | * 2 32-bit values, timeReference high and low |
||
| 182 | * @type {!Array<number>} |
||
| 183 | */ |
||
| 184 | timeReference: [0, 0], |
||
| 185 | /** @type {number} */ |
||
| 186 | version: 0, //WORD |
||
| 187 | /** @type {string} */ |
||
| 188 | UMID: '', // 64 chars |
||
| 189 | /** @type {number} */ |
||
| 190 | loudnessValue: 0, //WORD |
||
| 191 | /** @type {number} */ |
||
| 192 | loudnessRange: 0, //WORD |
||
| 193 | /** @type {number} */ |
||
| 194 | maxTruePeakLevel: 0, //WORD |
||
| 195 | /** @type {number} */ |
||
| 196 | maxMomentaryLoudness: 0, //WORD |
||
| 197 | /** @type {number} */ |
||
| 198 | maxShortTermLoudness: 0, //WORD |
||
| 199 | /** @type {string} */ |
||
| 200 | reserved: '', //180 |
||
| 201 | /** @type {string} */ |
||
| 202 | codingHistory: '' // string, unlimited |
||
| 203 | }; |
||
| 204 | /** |
||
| 205 | * The data of the 'ds64' chunk. |
||
| 206 | * Used only with RF64 files. |
||
| 207 | * @type {!Object<string, *>} |
||
| 208 | */ |
||
| 209 | this.ds64 = { |
||
| 210 | /** @type {string} */ |
||
| 211 | chunkId: '', |
||
| 212 | /** @type {number} */ |
||
| 213 | chunkSize: 0, |
||
| 214 | /** @type {number} */ |
||
| 215 | riffSizeHigh: 0, // DWORD |
||
| 216 | /** @type {number} */ |
||
| 217 | riffSizeLow: 0, // DWORD |
||
| 218 | /** @type {number} */ |
||
| 219 | dataSizeHigh: 0, // DWORD |
||
| 220 | /** @type {number} */ |
||
| 221 | dataSizeLow: 0, // DWORD |
||
| 222 | /** @type {number} */ |
||
| 223 | originationTime: 0, // DWORD |
||
| 224 | /** @type {number} */ |
||
| 225 | sampleCountHigh: 0, // DWORD |
||
| 226 | /** @type {number} */ |
||
| 227 | sampleCountLow: 0 // DWORD |
||
| 228 | /** @type {number} */ |
||
| 229 | //'tableLength': 0, // DWORD |
||
| 230 | /** @type {!Array<number>} */ |
||
| 231 | //'table': [] |
||
| 232 | }; |
||
| 233 | /** |
||
| 234 | * The data of the 'data' chunk. |
||
| 235 | * @type {!Object<string, *>} |
||
| 236 | */ |
||
| 237 | this.data = { |
||
| 238 | /** @type {string} */ |
||
| 239 | chunkId: '', |
||
| 240 | /** @type {number} */ |
||
| 241 | chunkSize: 0, |
||
| 242 | /** @type {!Uint8Array} */ |
||
| 243 | samples: new Uint8Array(0) |
||
| 244 | }; |
||
| 245 | /** |
||
| 246 | * The data of the 'LIST' chunks. |
||
| 247 | * Each item in this list look like this: |
||
| 248 | * { |
||
| 249 | * chunkId: '', |
||
| 250 | * chunkSize: 0, |
||
| 251 | * format: '', |
||
| 252 | * subChunks: [] |
||
| 253 | * } |
||
| 254 | * @type {!Array<!Object>} |
||
| 255 | */ |
||
| 256 | this.LIST = []; |
||
| 257 | /** |
||
| 258 | * The data of the 'junk' chunk. |
||
| 259 | * @type {!Object<string, *>} |
||
| 260 | */ |
||
| 261 | this.junk = { |
||
| 262 | /** @type {string} */ |
||
| 263 | chunkId: '', |
||
| 264 | /** @type {number} */ |
||
| 265 | chunkSize: 0, |
||
| 266 | /** @type {!Array<number>} */ |
||
| 267 | chunkData: [] |
||
| 268 | }; |
||
| 269 | /** |
||
| 270 | * The bit depth code according to the samples. |
||
| 271 | * @type {string} |
||
| 272 | */ |
||
| 273 | this.bitDepth = '0'; |
||
| 274 | /** |
||
| 275 | * @type {!Object} |
||
| 276 | * @protected |
||
| 277 | */ |
||
| 278 | this.dataType = {}; |
||
| 279 | /** |
||
| 280 | * @type {!Object} |
||
| 281 | * @protected |
||
| 282 | */ |
||
| 283 | this.uInt16 = {bits: 16, be: false}; |
||
| 284 | // Load a file from the buffer if one was passed |
||
| 285 | // when creating the object |
||
| 286 | if (wavBuffer) { |
||
| 287 | this.fromBuffer(wavBuffer); |
||
| 288 | } |
||
| 289 | } |
||
| 290 | |||
| 690 |